{template '_header'}

<div class="page-heading"> 
    <span class='pull-right'>
        {ifp 'qa.question.add'}
        	<a class="btn btn-primary btn-sm" href="{php echo webUrl('qa/question/add')}"><i class="fa fa-plus"></i> 添加问题</a>
        {/if}
    </span>
    <h2>问题管理 <small>(总数: {$total})</small></h2>
</div>

<form action="./index.php" method="get" class="form-horizontal" plugins="form">
    <input type="hidden" name="c" value="site">
    <input type="hidden" name="a" value="entry">
    <input type="hidden" name="m" value="ewei_shopv2">
    <input type="hidden" name="do" value="web">
    <input type="hidden" name="r" value="qa.question">
    <div class="page-toolbar row m-b-sm m-t-sm">
        <div class="col-sm-4">
            <div class="input-group-btn">
                <button class="btn btn-default btn-sm" type="button" data-toggle="refresh"><i class="fa fa-refresh"></i></button>
                {ifp 'qr.question.edit'}
                <button class="btn btn-default btn-sm" type="button" data-toggle="batch" data-href="{php echo weburl('qa/question/status', array('status'=>0))}" disabled="disabled"><i class="fa fa-circle-o"></i> 隐藏</button>
                <button class="btn btn-default btn-sm" type="button" data-toggle="batch" data-href="{php echo weburl('qa/question/status', array('status'=>1))}" disabled="disabled"><i class="fa fa-circle"></i> 显示</button>
                {/if}
                {ifp 'qr.question.delete'}
                <button class="btn btn-default btn-sm" type="button" data-toggle="batch-remove" data-confirm="确认要删除吗?" data-href="{php echo weburl('qr/question/delete')}" disabled="disabled"><i class="fa fa-trash"></i> 删除</button>
                {/if}

            </div>
        </div>
        <div class="col-sm-8 pull-right">
            <select name="status" class="form-control input-sm select-sm" style="width:75px;">
                <option value="">显示</option>
                <option value="1" {if $_GPC['status']=='1'} selected{/if}>是</option>
                <option value="0" {if $_GPC['status']=='0'} selected{/if}>否</option>
            </select>
            <select name="isrecommand" class="form-control input-sm select-sm" style="width:75px;">
                <option value="">推荐</option>
                <option value="1" {if $_GPC['isrecommand']=='1'} selected{/if}>是</option>
                <option value="0" {if $_GPC['isrecommand']=='0'} selected{/if}>否</option>
            </select>
            <select name="cate" class="form-control input-sm select-sm" style="width:120px;">
                <option value="">问题分类</option>
                {loop $category $item}
                <option value="{$item['id']}" {if intval($_GPC['cate'])==$item['id']} selected{/if}>{$item['name']}</option>
                {/loop}
            </select>
            <div class="input-group">
                <input type="text" class="input-sm form-control" name="keyword" value="{$_GPC['keyword']}" placeholder="请输入关键词"> <span class="input-group-btn">
                <button class="btn btn-sm btn-primary" type="submit"> 搜索</button> </span>
            </div>
        </div>
    </div>
</form>

{if count($list)>0}
<form action="" method="post">

    <table class="table table-hover table-responsive">
        <thead class="navbar-inner">
            <tr>
                <th style="width:50px;">
                    <input type="checkbox">
                </th>
                <th style='width:70px;'>排序</th>
                <th style="width: 120px;">问题分类</th>
                <th>问题名称</th>
                <th style="width: 50px; text-align: center;">推荐</th>
                <th style="width: 50px; text-align: center;">状态</th>
                <th style="width: 150px;">操作</th>
            </tr>
        </thead>
        <tbody id="sort">
            {loop $list $row}
            <tr>
                <td><input type="checkbox" value="{$row['id']}"></td>
                <td>
                    {ifp 'qa.question.edit'}
                    	<a href='javascript:;' data-toggle='ajaxEdit' data-href="{php echo webUrl('qa/question/displayorder',array('id'=>$row['id']))}" >{$row['displayorder']}</a>
                    {else}
                    	{$row['displayorder']} 
                    {/if}
                </td>
                <td>{if $row['cate']==0}未分类{else}{$row['catename']}{/if}</td>
                <td>{$row['title']}</td>
                <td style="text-align: center;">
                    <span class='label {if $row['isrecommand']==1}label-success{else}label-default{/if}'
                    {ifp 'qa.question.edit'}
                    data-toggle='ajaxSwitch'
                    data-switch-value='{$row['isrecommand']}'
                    data-switch-value0='0|否|label label-default|{php echo webUrl('qa/question/isrecommand',array('isrecommand'=>1,'id'=>$row['id']))}'
                    data-switch-value1='1|是|label label-success|{php echo webUrl('qa/question/isrecommand',array('isrecommand'=>0,'id'=>$row['id']))}'
                    {/if}
                    >
                    {if $row['isrecommand']==1}是{else}否{/if}</span>
                </td>
                <td style="text-align: center;">
                    <span class="label {if $row['status']==1}label-success{else}label-default{/if}"
                          {ifp 'qa.question.edit'}
	                          data-toggle='ajaxSwitch' 
	                          data-switch-value='{$row['status']}'
	                          data-switch-value0='0|隐藏|label label-default|{php echo webUrl('qa/question/status',array('status'=>1,'id'=>$row['id']))}'
	                          data-switch-value1='1|显示|label label-success|{php echo webUrl('qa/question/status',array('status'=>0,'id'=>$row['id']))}'
                          {/if}
                          >
                          {if $row['status']==1}显示{else}隐藏{/if}</span>
                    </td>
                    <td style="text-align:left;">
                        {ifp 'qa.question.view|qa.question.edit'}
	                        <a href="{php echo webUrl('qa/question/edit', array('id' => $row['id']))}" class="btn btn-default btn-sm" title="{ifp 'qa.question.edit'}编辑{else}查看{/if}">
	                        	<i class="fa fa-edit"></i> {ifp 'qa.question.edit'}修改{else}查看{/if}
	                        </a>
                        {/if}
                        {ifp 'qa.question.delete'} 
                        	<a data-toggle='ajaxRemove' href="{php echo webUrl('qa/question/delete', array('id' => $row['id']))}"class="btn btn-default btn-sm" data-confirm="确认删除此分类?" title="删除"><i class="fa fa-trash"></i> 删除</a>
                        {/if}
                    </td>
                </tr>
                {/loop} 
            </tbody>
        </table>
        {$pager}
        {else}
        <div class='panel panel-default'>
            <div class='panel-body' style='text-align: center;padding:30px;'>
                未找到相关问题
            </div>
        </div>
            {/if}
    </form>


    {template '_footer'}

